from PIL import Image, ImageFilter
import matplotlib.pyplot as plt

img = Image.open('zmg.jpeg')
blur_img = img.filter(ImageFilter.BLUR)  # 默认参数情况下的模糊滤波
contour_img = img.filter(ImageFilter.CONTOUR)  # 默认参数情况下的轮廓滤波
detail_img = img.filter(ImageFilter.DETAIL)  # 默认参数情况下的细节增强滤波
EDGE_ENHANCE_img = img.filter(ImageFilter.EDGE_ENHANCE)  # 默认参数情况下的边缘增强滤波
EDGE_ENHANCE_MORE_img = img.filter(ImageFilter.EDGE_ENHANCE_MORE)  # 默认参数情况下的深度边缘增强滤波
EMBOSS_img = img.filter(ImageFilter.EMBOSS)  # 默认参数情况下的浮雕滤波
FIND_EDGES_img = img.filter(ImageFilter.FIND_EDGES)  # 默认参数情况下的寻找边缘信息的滤波
SMOOTH_img = img.filter(ImageFilter.SMOOTH)  # 默认参数情况下的平滑滤波
SMOOTH_MORE_img = img.filter(ImageFilter.SMOOTH_MORE)  # 默认参数情况下的深度平滑滤波
SHARPEN_img = img.filter(ImageFilter.SHARPEN)  # 默认参数情况下的锐化滤波

plt.figure(num='ImageFilter滤波方法对比图', figsize=(13, 6), )
plt.subplot(2, 5, 1), plt.title('BLUR')
plt.imshow(blur_img), plt.axis('off')

plt.subplot(2, 5, 2), plt.title('CONTOUR')
plt.imshow(contour_img), plt.axis('off')

plt.subplot(2, 5, 3), plt.title('DETAIL')
plt.imshow(detail_img), plt.axis('off')

plt.subplot(2, 5, 4), plt.title('EDGE_ENHANCE')
plt.imshow(EDGE_ENHANCE_img), plt.axis('off')

plt.subplot(2, 5, 5), plt.title('EDGE_ENHANCE_MORE')
plt.imshow(EDGE_ENHANCE_MORE_img), plt.axis('off')

plt.subplot(2, 5, 6), plt.title('EMBOSS')
plt.imshow(EMBOSS_img), plt.axis('off')

plt.subplot(2, 5, 7), plt.title('FIND_EDGES')
plt.imshow(FIND_EDGES_img), plt.axis('off')

plt.subplot(2, 5, 8), plt.title('SMOOTH')
plt.imshow(SMOOTH_img), plt.axis('off')

plt.subplot(2, 5, 9), plt.title('SMOOTH_MORE')
plt.imshow(SMOOTH_MORE_img), plt.axis('off')

plt.subplot(2, 5, 10), plt.title('SHARPEN')
plt.imshow(SHARPEN_img), plt.axis('off')
plt.show()
